package com.ash.hutool;

import cn.hutool.core.date.DateUtil;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class WorkDaysTest {


    public static void main(String[] args) {
        test("2023-09-01", "2023-09-30");
    }

    public static void test(String st, String et) {
        List<Integer> collect = Stream.of(10).peek(System.out::println).collect(Collectors.toList());
        System.out.println(collect);
        test(DateUtil.parseDate(st).toLocalDateTime().toLocalDate(), DateUtil.parseDate(et).toLocalDateTime().toLocalDate());
    }


    public static void test(LocalDate st, LocalDate et) {
        int workDays = 0;
        LocalDate bt = st;

        while (bt.compareTo(et) <= 0) {
            // 判断是否特殊日期

            // 判断是否周六周日
            DayOfWeek dayOfWeek = bt.getDayOfWeek();
            if (dayOfWeek == DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY) {
                bt = bt.plusDays(1);
                continue;
            }

            workDays++;
            System.out.println(bt);

            bt = bt.plusDays(1);
        }

        System.out.println(workDays);
    }
}
